import axios from "axios";

const state={
    adminName:localStorage.adminName,
    token:localStorage.token,
    personnerLog: [] 
}
const mutations={
    CHANGE_PERSONNER_LOG(state, personnerLog){
        state.personnerLog = personnerLog;
    },
    CHANGE_LOGIN_INFO(state,info){
        state.adminName = localStorage.adminName =  info.adminName;
        state.token = localStorage.token = info.token;
        state.status=info.status;
        // console.log(typeof(state.status))
    },
}

const actions={
    async getPersonnerLog({commit}, query={}){
        const {pageIndex =1 } = query;
        const data =await axios.get("/personnerLog",{
            params:{
                pageIndex
            }
        });
        commit("CHANGE_PERSONNER_LOG", data.personnerLog);
        // console.log(data)
        return data;
    }
}

export default {
    state,
    actions,
    mutations
}